package com.app.Timer;

import com.app.model.main.SystemMessage;
import com.app.repository.interfaces.SystemMessageMapper;
import com.app.service.push.PushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Lichaojie on 2017/8/21. It's a beautiful day.
 */
@Component
public class PushTimer {

    @Autowired
    private SystemMessageMapper systemMessageMapper;
    @Autowired
    private PushService pushService;

    //@Scheduled(fixedRate = 5*60*1000)//间隔5分钟
    public void pushSystemMessage(){
        List<SystemMessage> systemMessageList = systemMessageMapper.getUnPushedSystemMessage();
        for (SystemMessage systemMessage : systemMessageList){
            pushService.pushSystemMessage(systemMessage);
        }
    }


}
